home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / Suite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-18  |  12.6 KB  |  306 lines

  1. /*
  2. //   (C) COPYRIGHT International Business Machines Corp. 1993
  3. //   All Rights Reserved
  4. //   Licensed Materials - Property of IBM
  5. //   US Government Users Restricted Rights - Use, duplication or
  6. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8.  
  9. //
  10. // Permission to use, copy, modify, and distribute this software and its
  11. // documentation for any purpose and without fee is hereby granted, provided
  12. // that the above copyright notice appear in all copies and that both that
  13. // copyright notice and this permission notice appear in supporting
  14. // documentation, and that the name of I.B.M. not be used in advertising
  15. // or publicity pertaining to distribution of the software without specific,
  16. // written prior permission. I.B.M. makes no representations about the
  17. // suitability of this software for any purpose.  It is provided "as is"
  18. // without express or implied warranty.
  19. //
  20. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  22. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  23. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  24. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  25. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. // Author:  John Spitzer, IBM AWS Graphics Systems (Austin)
  28. //
  29. */
  30. #ifdef WIN32
  31. #include <windows.h>
  32. #include <gl\glaux.h>
  33. #elif __amigaos__
  34. #include <gl/glaux.h>
  35. #else
  36. #include "aux.h"
  37. #endif
  38.  
  39. #include "Suite.h"
  40. #include <malloc.h>
  41.  
  42. extern int yylineno;
  43.  
  44. SuitePtr new_Suite()
  45. {
  46.     SuitePtr this = (SuitePtr)malloc(sizeof(Suite));
  47.     int i;
  48.     CheckMalloc(this);
  49.     /* initialize masterList to one instantiation of each leaf class */
  50.     for (i=0; i<NumLeafClasses; i++) {
  51.     this->masterList[i] = new_TestList();
  52.     this->sortList[i] = new_TestList();
  53.     }
  54.     TestList__AddTest(this->masterList[ClearTest         - ClearTest], (TestPtr) new_Clear());
  55.     TestList__AddTest(this->masterList[TransformTest     - ClearTest], (TestPtr) new_Transform());
  56.     TestList__AddTest(this->masterList[PointsTest        - ClearTest], (TestPtr) new_Points());
  57.     TestList__AddTest(this->masterList[LinesTest         - ClearTest], (TestPtr) new_Lines());
  58.     TestList__AddTest(this->masterList[LineLoopTest      - ClearTest], (TestPtr) new_LineLoop());
  59.     TestList__AddTest(this->masterList[LineStripTest     - ClearTest], (TestPtr) new_LineStrip());
  60.     TestList__AddTest(this->masterList[TrianglesTest     - ClearTest], (TestPtr) new_Triangles());
  61.     TestList__AddTest(this->masterList[TriangleStripTest - ClearTest], (TestPtr) new_TriangleStrip());
  62.     TestList__AddTest(this->masterList[TriangleFanTest   - ClearTest], (TestPtr) new_TriangleFan());
  63.     TestList__AddTest(this->masterList[QuadsTest         - ClearTest], (TestPtr) new_Quads());
  64.     TestList__AddTest(this->masterList[QuadStripTest     - ClearTest], (TestPtr) new_QuadStrip());
  65.     TestList__AddTest(this->masterList[PolygonTest       - ClearTest], (TestPtr) new_Polygon());
  66.     TestList__AddTest(this->masterList[DrawPixelsTest    - ClearTest], (TestPtr) new_DrawPixels());
  67.     TestList__AddTest(this->masterList[CopyPixelsTest    - ClearTest], (TestPtr) new_CopyPixels());
  68.     TestList__AddTest(this->masterList[BitmapTest        - ClearTest], (TestPtr) new_Bitmap());
  69.     TestList__AddTest(this->masterList[TextTest          - ClearTest], (TestPtr) new_Text());
  70.     TestList__AddTest(this->masterList[ReadPixelsTest    - ClearTest], (TestPtr) new_ReadPixels());
  71.     TestList__AddTest(this->masterList[TexImageTest      - ClearTest], (TestPtr) new_TexImage());
  72.     return this;
  73. }
  74.  
  75. void delete_Suite(SuitePtr this)
  76. {
  77.     int i;
  78.     for (i=0; i<NumLeafClasses; i++) {
  79.     delete_TestList(this->masterList[i]);
  80.     delete_TestList(this->sortList[i]);
  81.     }
  82.     free(this);
  83.     auxQuit();
  84. }
  85.  
  86. void Suite__ParseGlobal(SuitePtr this, PropertyPtr prop)
  87. {
  88.     int i, j, k, l;
  89.     TestPtr t, t_new;
  90.     TestListPtr oldList,newList;
  91.     AttributePtr attr;
  92.     int invalidProperty;
  93.     int validProperty = False;
  94.     int ivalue;
  95.     PropNameListPtr propNameList = prop->propNameList;
  96.     AttributeListPtr attrList = prop->attrList;
  97.     AttributeListPtr allAttrList;
  98.     TestListPtr *masterList = this->masterList;
  99.     char badProp[128];
  100.  
  101.     for (i=ClearTest; i<ClearTest+NumLeafClasses; i++) {
  102.     oldList = masterList[i];
  103.     newList = new_TestList();
  104.     invalidProperty = False;
  105.         t = NULL;
  106.     for (j=0; j < TestList__Size(oldList) && !invalidProperty; j++) {
  107.         t = oldList->list[j];
  108.         if (AttributeList__Size(attrList) == 1 && 
  109.                 Attribute__IntOf(attrList->list[0], &ivalue) && 
  110.                 ivalue == WildCard) {
  111.         if (PropNameList__Size(propNameList) > 1) {
  112.             printf("GLperf: Line %d, wildcard not valid for multiple properties\n", Attribute__GetLineNum(attrList->list[0]));
  113.             exit(1);
  114.         }
  115.         if (!(allAttrList = GetAllAttrs(t, propNameList->list[0]))) {
  116.             invalidProperty = True;
  117.         } else {
  118.             delete_AttributeList(attrList);
  119.             attrList = prop->attrList = allAttrList;
  120.             validProperty = True;
  121.         }
  122.         }
  123.         for (k=0; k < AttributeList__Size(attrList) && !invalidProperty; k++) {
  124.         int addTest = -1; /* Neither True nor False */
  125.         attr = attrList->list[k];
  126.         t_new = (*t->Copy)(t);
  127.         for (l = 0; l < PropNameList__Size(propNameList); l++) {
  128.                     switch (Apply(t_new, propNameList->list[l], attr)) {
  129.                         case InvalidProperty:
  130.                             invalidProperty = True;
  131.                 addTest = False;
  132.                 /* Delay deleting test until all properties are done */
  133.                             break;
  134.                         case InvalidValue:
  135.                             if (Table__InverseLookup(properties, badProp, propNameList->list[l])) {
  136.                                 printf("GLperf: Line %d, value not valid for property \"%s\"\n", propNameList->linenum[l], badProp);
  137.                             } else {
  138.                                 printf("GLperf: Line %d, value not valid for unknown property\n", propNameList->linenum[l]);
  139.                             }
  140.                             exit(1);
  141.                             break;
  142.                         case ApplySuccessful:
  143.                             validProperty = True;
  144.                 addTest = (addTest == False) ? False : True;
  145.                 /* Delay adding test until all properties are done */
  146.                             break;
  147.                         case PropertyNotSettable:
  148.                             printf("GLperf: Line %d, property not user settable\n", propNameList->linenum[l]);
  149.                 exit(1);
  150.                             break;
  151.                     }
  152.                 }
  153.         if (addTest == True) {
  154.             TestList__AddTest(newList, t_new);
  155.         } else if (addTest == False) {
  156.             (*t_new->delete)(t_new);
  157.         }
  158.         }
  159.     }
  160.     if (TestList__Size(newList)) {
  161.         delete_TestList(oldList);
  162.         masterList[i] = newList;
  163.     } else {
  164.         delete_TestList(newList);
  165.     }
  166.     }
  167.     if (!validProperty) {
  168.     if (Table__InverseLookup(properties, badProp, propNameList->list[0])) {
  169.         printf("GLperf: Line %d, wildcard attribute not valid for property \"%s\"\n", propNameList->linenum[l], badProp);
  170.     } else {
  171.         printf("GLperf: Line %d, wildcard attribute not valid for unknown property\n", propNameList->linenum[l]); 
  172.     }
  173.     exit(1);
  174.     }
  175.     delete_Property(prop);
  176. }
  177.  
  178. void Suite__ParseTest(SuitePtr this, int testType, PropertyListPtr propList)
  179. {
  180.     int i, j, k, l;
  181.     TestPtr t, t_new;
  182.     TestListPtr oldList,newList;
  183.     PropertyPtr property;
  184.     PropNameListPtr propNameList;
  185.     int ivalue;
  186.     AttributePtr attr;
  187.     AttributeListPtr attrList;
  188.     TestListPtr *sortList = this->sortList;
  189.     TestListPtr *masterList = this->masterList;
  190.     char badProp[128];
  191.     char badTest[128];
  192.     char badAttr[128];
  193.  
  194.     oldList = new_TestList();
  195.     TestList__Copy(oldList, masterList[testType - ClearTest]);
  196.     if (propList) {
  197.         for (i=0; i<PropertyList__Size(propList); i++) {
  198.             property = propList->list[i];
  199.             propNameList = property->propNameList;
  200.             attrList = property->attrList;
  201.             newList = new_TestList();
  202.             for (j=0; j < TestList__Size(oldList); j++) {
  203.                 t = oldList->list[j];
  204.                 if (AttributeList__Size(attrList) == 1 && 
  205.                     Attribute__IntOf(attrList->list[0], &ivalue) && 
  206.                     ivalue == WildCard) {
  207.                     if (PropNameList__Size(propNameList) > 1) {
  208.                         printf("GLperf: Line %d, wildcard not valid for multiple properties\n", propNameList->linenum[0]);
  209.                         exit(1);
  210.                     }
  211.                     delete_AttributeList(attrList);
  212.                     if (!(attrList = property->attrList = GetAllAttrs(t, propNameList->list[0]))) {
  213.             if (Table__InverseLookup(properties, badProp, propNameList->list[0])) {
  214.                     printf("GLperf: Line %d, wildcard attribute not valid for property \"%s\"\n", propNameList->linenum[0], badProp);
  215.             } else {
  216.                     printf("GLperf: Line %d, wildcard attribute not valid for unknown property\n", propNameList->linenum[0]); 
  217.             }
  218.                         exit(1);
  219.                     }
  220.                 }
  221.                 for (k=0; k < AttributeList__Size(attrList); k++) {
  222.                     attr = attrList->list[k];
  223.                     t_new = t->Copy(t);
  224.             for (l = 0; l < PropNameList__Size(propNameList); l++) {
  225.                         switch (Apply(t_new, propNameList->list[l], attr)) {
  226.                             case InvalidProperty:
  227.                     if (Table__InverseLookup(properties, badProp, propNameList->list[l]) &&
  228.                                     Table__InverseLookup(tests, badTest, testType)) {
  229.                             printf("GLperf: Line %d, property \"%s\" not valid for %s\n", propNameList->linenum[l], badProp, badTest);
  230.                     } else {
  231.                             printf("GLperf: Line %d, invalid property\n", propNameList->linenum[l]); 
  232.                     }
  233.                                 exit(1);
  234.                                 break;
  235.                             case InvalidValue:
  236.                     if (Table__InverseLookup(properties, badProp, propNameList->list[l])) {
  237.                             printf("GLperf: Line %d, value not valid for property \"%s\"\n", propNameList->linenum[l], badProp);
  238.                     } else {
  239.                             printf("GLperf: Line %d, value not valid for unknown property\n", propNameList->linenum[l]); 
  240.                     }
  241.                                 exit(1);
  242.                                 break;
  243.                             case ApplySuccessful:
  244.                 /* Don't add list yet, wait for all properties to complete */
  245.                                 break;
  246.                             case PropertyNotSettable:
  247.                                 printf("GLperf: Line %d, property not user settable\n", propNameList->linenum[l]);
  248.                     exit(1);
  249.                                 break;
  250.                 }
  251.                     }
  252.                     TestList__AddTest(newList, t_new);
  253.                 }
  254.             }
  255.             if (TestList__Size(newList)) {
  256.                 delete_TestList(oldList);
  257.                 oldList = newList;
  258.             } else {
  259.                 delete_TestList(newList);
  260.             }   
  261.         }  /* end for */
  262.         delete_PropertyList(propList);
  263.     } /* end if */
  264.     TestList__AddTestList(sortList[testType - ClearTest], oldList);
  265.     delete_TestList(oldList);
  266. }
  267.  
  268. void Suite__Run(SuitePtr this, int printMode)
  269. {
  270.     Visual_ID prevVisual = NoVisual; /* This data must be maintained across tests */
  271.     GLenum prevWindType = -1;
  272.     int prevWinW   = -1;       /* Ditto                                     */
  273.     int prevWinH   = -1;       /* Ditto                                     */
  274.     TestPtr prevTest;
  275.     int i, j;
  276.     TestListPtr *sortList = this->sortList;
  277.  
  278.     for (i=0; i<NumLeafClasses; i++) {
  279.         if (TestList__Size(sortList[i])) {
  280.             prevTest = 0;
  281.             for (j=0; j<TestList__Size(sortList[i]); j++) {
  282.                 TestPtr currentTest = sortList[i]->list[j];
  283.                 currentTest->previousWindType = prevWindType;
  284.                 currentTest->previousVisual = prevVisual;
  285.                 currentTest->previousWinW = prevWinW;
  286.                 currentTest->previousWinH = prevWinH;
  287.                 if (Test__SetupRunPrint(currentTest, prevTest, printMode)) {
  288.                     prevTest = currentTest;
  289.                     prevWindType = currentTest->windType;
  290. #if defined(XWINDOWS) || defined( __OS2__)
  291.                     prevVisual = currentTest->environ.bufConfig.visualId;
  292. #elif defined(WIN32)
  293.             prevVisual = currentTest->environ.bufConfig.ipfd;
  294. #elif defined(__amigaos__)
  295.             
  296. #else
  297. #error Window system undefined
  298. #endif
  299.                     prevWinW   = currentTest->environ.windowWidth;
  300.                     prevWinH   = currentTest->environ.windowHeight;
  301.         }
  302.             }
  303.         }
  304.     }
  305. }
  306.